var pretd = document.getElementById("pretd");
var nexttd = document.getElementById("nexttd");
var picseltd = document.getElementById("picseltd");
var pictypetd = document.getElementById("pictypetd");
var othertd = document.getElementById("othertd");
var ashovertd = picseltd.getElementsByTagName("a");
var astypetd = document.getElementById("atd");
var oastypetd = othertd.getElementsByTagName("a");
othertd.innerHTML = pictypetd.innerHTML;
var ytd = 42;
var ttd = 46;
var ntd = 130;
var qtd = 0;
var xtd = 6;
var sel_numtd = picseltd.offsetHeight/ytd;
var ztd = sel_numtd - 5;
if(sel_numtd > 5){nexttd.className = "nexttd";}
var ftd=0;
var timetd=8000;
function showtd(){
ftd=ftd>ashovertd.length-1?0:ftd;
for(itd = 0; itd < ashovertd.length; itd++){
 if(itd==ftd){
 				ashovertd[itd].className = "selbgtd";
				pictypetd.style.marginTop = -ntd*ftd + "px";
				othertd.style.marginTop = -ntd*ftd + "px";
				coolshowtd();
			}
 else {ashovertd[itd].className = "";}
}
ftd++;
if(ftd>3){addatd();}else{addctd();}
}
var ssoctd = setInterval("showtd()",timetd);
function coolshowtd(){
var onumtd = 9;
var ssoatd = setInterval(show_oatd,30);
	function show_oatd(){if(onumtd == 0){clearInterval(ssoatd);}}	
}
nexttd.onclick = addatd;
nexttd.onmouseover = function() {clearInterval(ssoctd);} 
nexttd.onmouseout = function() {ssoctd = setInterval("showtd()",timetd);} 
function addatd(){
	if(sel_numtd > 5){	
		var wtd = 0;
		var otd = -ytd*qtd;
		xtd++;
		pretd.className = "pretd2";
		if(qtd == 0 || qtd > 0){qtd++;}
		var sswtd = setInterval(show_wtd,10);
	}
	function show_wtd(){
		if(qtd < ztd || qtd == ztd){wtd-=3;picseltd.style.marginTop = (otd + wtd) + "px";}	
		if(wtd < -ytd+1){clearInterval(sswtd);}
		if(qtd > ztd){qtd = ztd;clearInterval(sswtd);}
	}
	if(xtd-sel_numtd == 0){nexttd.className = "nexttd2";}
	if(xtd-sel_numtd > 0){xtd = sel_numtd;}
}
pretd.onclick = addbtd;
pretd.onmouseover = function() {clearInterval(ssoctd);}
pretd.onmouseout = function() {ssoctd = setInterval("showtd()",timetd);} 
function addbtd(){
	if(xtd > 5){
		var wtd = 0;
		var otd = -ytd*qtd;
		xtd--;
		nexttd.className = "nexttd"
		qtd--;
		var sswbtd = setInterval(show_wbtd,10);
	}
	function show_wbtd(){
		if(qtd < ztd || qtd == ztd){wtd-=3;picseltd.style.marginTop = (otd + -wtd) + "px";}
		if(wtd < -ytd+1){clearInterval(sswbtd);}				
	}
	if(xtd == 5){pretd.className = "pretd";nexttd.className = "nexttd";}
}
function addctd(){
	if(xtd > 5){
		var o = -ytd*qtd;
		xtd--;
		nexttd.className = "nexttd"
		qtd--;		
	}
	picseltd.style.marginTop = 0 + "px";
	pretd.className = "pretd";
	nexttd.className = "nexttd";
}
for(itd = 0; itd < oastypetd.length; itd++){
	oastypetd[itd].onmouseover = function() {clearInterval(ssoctd);}
	oastypetd[itd].onmouseout = function() {ssoctd = setInterval("showtd()",timetd);} 
}
for(itd = 0; itd < ashovertd.length; itd++){
	ashovertd[itd].num = itd;
	ashovertd[itd].onmouseover = typestyletd;
	ashovertd[itd].onmouseout = function() {ftd = this.num+1;ssoctd = setInterval("showtd()",timetd);} 
}
function typestyletd(){
	for(itd = 0; itd < ashovertd.length; itd++){ashovertd[itd].className = "";}
	ashovertd[this.num].className = "selbgtd";
	var std = this.num
	var otd = -ntd*std;
	var vtd = -ttd*std;
	pictypetd.style.marginTop = otd + "px";
	othertd.style.marginTop = otd + "px";
	coolshowtd();
	clearInterval(ssoctd);
}
function H$(i) {return document.getElementById(i)}
function H$$(c, p) {return p.getElementsByTagName(c)}
var slider = function () {
 function init (o) {this.id = o.id;this.at = o.auto ? o.auto : 3;this.o = 0;this.pos();}
 init.prototype = {
  pos : function () {
   clearInterval(this.__b);
   this.o = 0;
   var el = H$(this.id), li = H$$('li', el), l = li.length;
   var _t = li[l-1].offsetHeight;
   var cl = li[l-1].cloneNode(true);
   cl.style.opacity = 0; cl.style.filter = 'alpha(opacity=0)';
   el.insertBefore(cl, el.firstChild);
   el.style.top = -_t + 'px';
   this.anim();
  },
  anim : function () {var _this = this;this.__a = setInterval(function(){_this.animH()}, 20);},
  animH : function () {
   var _t = parseInt(H$(this.id).style.top), _this = this;
   if (_t >= -1) {
    clearInterval(this.__a);
    H$(this.id).style.top = 0;
    var list = H$$('li',H$(this.id));
    H$(this.id).removeChild(list[list.length-1]);
    this.__c = setInterval(function(){_this.animO()}, 20);
   }else {var __t = Math.abs(_t) - Math.ceil(Math.abs(_t)*.07);H$(this.id).style.top = -__t + 'px';}
  },
  animO : function () {
   this.o += 2;
   if (this.o == 50) {
    clearInterval(this.__c);
    H$$('li',H$(this.id))[0].style.opacity = 1;
    H$$('li',H$(this.id))[0].style.filter = 'alpha(opacity=100)';
    this.auto();
   }else {H$$('li',H$(this.id))[0].style.opacity = this.o/50;H$$('li',H$(this.id))[0].style.filter = 'alpha(opacity='+this.o+')';}
  },
  auto : function () {var _this = this;this.__b = setInterval(function(){_this.pos()}, this.at*3000);}
 }
 return init;
}();